/**
 * 
 */
package hr.fer.zemris.annotator.factories;

import java.util.ArrayList;
import java.util.List;

import hr.fer.zemris.annotator.model.Method;
import hr.fer.zemris.annotator.model.interfaces.ICallGraphDataFactory;
import hr.fer.zemris.annotator.model.interfaces.IMethodMappingDataFactory;
import hr.fer.zemris.annotator.model.profiling.FlatProfileData;
import hr.fer.zemris.annotator.model.profiling.MethodMappingData;

/**
 * @author dajan
 *
 */
public class MethodMappingDataFactory implements IMethodMappingDataFactory{

	private static IMethodMappingDataFactory instance = null;

	public static IMethodMappingDataFactory getInstance() {
		if (instance == null) {
			instance = new MethodMappingDataFactory();
		}
		return instance;
	}
	
	@Override
	public List<MethodMappingData> getMethodMapping(String line) {
		
		String[] lineSplit = line.split(" ");
		List<String> methodMappingString = new ArrayList<String>();
		List<MethodMappingData> methodMapping = new ArrayList<MethodMappingData>();
		

		for (int i = 0, j = 0; i < lineSplit.length; i++) {
			if (!lineSplit[i].equals("")) {
				methodMappingString.add(lineSplit[i]);
			}
		}
		
		methodMapping.add(new MethodMappingData(methodMappingString.get(0), methodMappingString.get(1)));
		
		if(methodMappingString.size() > 2){
			
			methodMapping.add(new MethodMappingData(methodMappingString.get(2), methodMappingString.get(3)));
			
		}
		
		return methodMapping;
	}

}
